package edu.scau.tool.sevice;

import edu.scau.core.util.ServletUtils;
import edu.scau.system.service.TokenService;
import edu.scau.tool.domain.Logs;
import edu.scau.tool.mapper.LogsMapper;
import edu.scau.tool.vo.LogsVo;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class LogsServiceImpl implements LogsService{
    @Autowired
    private LogsMapper logsMapper;
    @Autowired
    private TokenService tokenService;
    @Override
    public List<LogsVo> listAll() {
        return logsMapper.listAll();
    }

    @Override
    public LogsVo findLogsById(Long id) {
        return logsMapper.findLogsById(id);
    }

    @Override
    public int insertLogs(Logs logs) {
        String createBy=tokenService.getLoginUser(ServletUtils.getRequest()).getUsername();
        Date date=new Date();
        logs.setCreateBy(createBy);
        logs.setCreateTime(date);
        return logsMapper.insertLogs(logs);
    }
}
